package com.weizhu.swufer.core.metrics;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class MetricsManager {

    private final static ConcurrentMap<String, RpcMetrics> SERVER_METRICS = new ConcurrentHashMap<>();

    private final static ConcurrentMap<String, RpcMetrics> METHOD_METRICS = new ConcurrentHashMap<>();


    public static RpcMetrics getServerRpcMetrics(String serverAddress){
        return SERVER_METRICS.computeIfAbsent(serverAddress, key -> new RpcMetrics(serverAddress));
    }

    public static RpcMetrics getMethodRpcMetrics(String method){
        return METHOD_METRICS.computeIfAbsent(method, key -> new RpcMetrics(method));
    }

    public static ConcurrentMap<String, RpcMetrics> getServerMetrics() {
        return SERVER_METRICS;
    }
}
